
function validateEmpty(ele, text) {
	obj = document.getElementById(ele);
	if (trim(obj.value)=="") {
		alert("El campo "+text+" es requerido");
		return false;
	}
	return true;
}

function trim(trim_value){
	if(trim_value.length < 1){
		return "";
	}
	trim_value = rtrim(trim_value);
	trim_value = ltrim(trim_value);
	if(trim_value==""){
		return "";
	}	else{
		return trim_value;
	}
}

function rtrim(valor){
	var w_space = String.fromCharCode(32);
	var v_length = valor.length;
	var strTemp = "";
	if(v_length < 0){
		return "";
	}
	var iTemp = v_length -1;
	
	while(iTemp > -1){
		if(valor.charAt(iTemp) == w_space){
		}	else{
			strTemp = valor.substring(0,iTemp +1);
			break;
		}
		iTemp = iTemp-1;
	} //End While
	return strTemp;

} //End Function

function ltrim(VALUE){
	var w_space = String.fromCharCode(32);
	if(v_length < 1){
		return"";
	}
	var v_length = VALUE.length;
	var strTemp = "";
	
	var iTemp = 0;
	
	while(iTemp < v_length){
		if(VALUE.charAt(iTemp) == w_space){
		}	else{
			strTemp = VALUE.substring(iTemp,v_length);
			break;
		}
		iTemp = iTemp + 1;
	} //End While
	return strTemp;
} //End Function